package com.hengpeng.itfints.constants;

import com.hengpeng.common.cis.ComponentContextLoader;
import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.itfinbase.constants.SystemConfigConstants;
import com.hengpeng.itfinbase.persist.Partner;
import com.hengpeng.itfinbase.persist.Partner.PartnerType;
import com.hengpeng.itfints.service.ServiceFactory;

public class PartnerUtil {

    private static ServiceFactory configService = ComponentContextLoader.getBean(ServiceFactory.class);

    public static boolean isTrustPattern() {
        DynamicQuery query = new DynamicQuery(Partner.class);
        query.eq("id", SystemConfigUtil.getConfigValue(SystemConfigConstants.PARTNER_ID));
        Partner partner = configService.getPersistService().getEntity(query, Partner.class);
        if (partner != null && !partner.getPartnerType().equals(PartnerType.FUND)) {
            return true;
        } else {
            return false;
        }
    }

    public static PartnerType getPartnerType() {
        DynamicQuery query = new DynamicQuery(Partner.class);
        query.eq("id", SystemConfigConstants.PARTNER_ID);
        Partner partner = configService.getPersistService().getEntity(query, Partner.class);
        return partner.getPartnerType();
    }
}
